import { type IDomEditor, SlateElement, DomEditor } from "@wangeditor/editor";
import { h, VNode } from "snabbdom";
import { constant, AttachmentElement } from "./constant";
/**
 * 渲染“附件”元素到编辑器
 * @param elem 附件元素
 * @param children 元素子节点，void 元素可忽略
 * @param editor 编辑器实例
 * @returns vnode 节点（通过 snabbdom.js 的 h 函数生成）
 */
function renderAttachment(elem: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode {
  const { value = "" } = elem as AttachmentElement;
  return h(
    "div",
    {
      style: { "font-size": "14px", padding: "10px", color: "#544343", "background-color": "rgb(238 238 238)", border: "1px solid #dac0c0", "border-radius": "5px" }
    },
    [value]
  );
}
const renderElemConf = {
  type: constant.type,
  renderElem: renderAttachment
};

export default renderElemConf;
